- 3 minutes to read

How to enable the WCF Diagnostics Tracing Feature

Learn how to enable WCF Diagnostics to enable Logging with Nodinite. To enable WCF Diagnostics logging, follow the steps below.

First, make sure you comply with the prerequisites.

Enable Logging

Repeat the steps as required to enable logging for multiple WCF applications.

Step 1: Copy files from ZIP

If you already performed this step during the installation, then go to the next step. Otherwise, copy the files from the ZIP package, and make sure Windows does not block them.

Step 2: Edit configuration section

Open your web/app.config and add/modify the <system.diagnostics> section as detailed below:

Note

The Nodinite Pickup Service consumes the output files. Make sure to set the PickupFolder and the LogAgentId property to identify logging into the Nodinite Log API.

Required

  • PickupFolder - Folder where to write the WCF Diagnostics output files, for example C:\Temp\Nodinite.LogAgent.WCFDiagnostics42.
  • LogAgentId - The unique LogAgentId, see Log Agents for additional details, for example 42.

Optional

  • DefaultMessageType - Default Message Type or if it can't be resolved when MessageTypeFromBody = true, default value if not set is "IM.LogAgent.WCFDiagnostics/1.0#DefaultMessageType".
  • MessageTypeFromBody - If message type should try to be extracted from XPath /MessageLogTraceRecord/Envelope/Body on first child. If found the Message Type is set to namespace#node. Default=false
<system.diagnostics>
  <sources>
    <source name="System.ServiceModel" switchValue="Information, ActivityTracing">
      <listeners>
        <add name="Nodinite.LogAgent.WCFDiagnostics" />
      </listeners>
    </source>
    <source name="System.ServiceModel.MessageLogging" switchValue="Information, ActivityTracing">
      <listeners>
        <add name="Nodinite.LogAgent.WCFDiagnostics" />
      </listeners>
    </source>
  </sources>
  <sharedListeners>
    <add type="Nodinite.LogAgent.WCFDiagnostics.EventJsonWriterTraceListener, Nodinite.LogAgent.WCFDiagnostics" name="Nodinite.LogAgent.WCFDiagnostics" traceOutputOptions="None" PickupFolder="C:\Temp\Nodinite.LogAgent.WCFDiagnostics42" LogAgentId="42" DefaultMessageType="" MessageTypeFromBody="true" DefaultEndPointName="" DefaultEndPointUri="" IncomingEventTimeout="10">
      <filter type="" />
    </add>
  </sharedListeners>
  <trace autoflush="true" />
</system.diagnostics>

* name - should not be changed. If you do change it you need to replace all occurrences:
Trace Name Property

Step 3: Edit system.serviceModel section

Open your web/app.config and add/modify <system.serviceModel> section.

<diagnostics>
  <messageLogging
    logEntireMessage="true"
    logMalformedMessages="true"
    logMessagesAtServiceLevel="true"
    logMessagesAtTransportLevel="true"
    maxMessagesToLog="100000000"
    maxSizeOfMessageToLog="536870912"
  />
</diagnostics>

Step 4: Configure Newtonsoft version

Make sure to set the correct version of the Newtonsoft dll in the attribute newVersion, 9.0.0.0 is default with the downloaded version. Open your web/app.config and add/modify section.

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
      <bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="9.0.0.0" />
    </dependentAssembly>
  </assemblyBinding>
</runtime>

Step 5: Save

Note

Make sure to save changes when done.

Step 6: Configure Pickup Service

Now install and configure the Nodinite Pickup service to fetch log files from the PickupFolder and log to the Nodinite Log API:

Step 7: Configure Log Views

Now Add or manage Log Views and use the Log Views to view the WCF Diagnostic output.


Next Step